package com.fastCms.business.bim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fastCms.business.frame.constant.CommonConst;
import com.fastCms.business.bim.daos.DataMockMapper;
import com.fastCms.business.bim.pojo.entity.DataMock;
import com.fastCms.business.bim.service.DataMockService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 区域管理 服务实现类
 * </p>
 *
 * @author liusq
 * @since 2021-04-05
 */
@Service
public class DataMockServiceImpl extends ServiceImpl<DataMockMapper, DataMock> implements DataMockService {

    @Override
    public DataMock findByCode(String code) {
        QueryWrapper<DataMock> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        queryWrapper.eq("code", code);
        return getOne(queryWrapper);
    }

    @Override
    public List<DataMock> findValidAll(String search) {
        QueryWrapper<DataMock> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        if (StringUtils.isNotBlank(search)) {
            queryWrapper.like("code_name", search);
        }
        return list(queryWrapper);
    }

}
